package ue.client.planets.tiles;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

/**
 * Represents the image of a tile.
 * @author Lueko
 *
 */
public class TileGraphic {

    public int WIDTH;
    public int HEIGHT;
    public Image image;
    
    /**
     * Creates a TileGraphic out of an image.
     * @param WIDTH Width of the TileGraphic.
     * @param HEIGHT Height of the TileGraphic.
     * @param x X position in the image array.
     * @param y Y position in the image array.
     * @param images Image array with the images.
     */
    public TileGraphic(int WIDTH, int HEIGHT, int x, int y, Image[][] images) {
        this.WIDTH = WIDTH;
        this.HEIGHT = HEIGHT;
        image = images[x][y];
    }
    
    /**
     * Creates a TileGraphic with a specified color.
     * @param WIDTH Width of the TileGraphic.
     * @param HEIGHT Height of the TileGraphic.
     * @param color Color of the TileGraphic.
     */
    public TileGraphic(int WIDTH, int HEIGHT, Color color) {
        this.WIDTH = WIDTH;
        this.HEIGHT = HEIGHT;
        try {
			image = new Image(WIDTH, HEIGHT);
		} catch (SlickException e1) {
			e1.printStackTrace();
		}
        Graphics g2d = new Graphics();
		try {
			g2d = image.getGraphics();
		} catch (SlickException e) {
			e.printStackTrace();
		}
        g2d.setColor(color);
        g2d.fillRect(0, 0, WIDTH, HEIGHT);
    }
    
}